<?php
namespace BP\DA;

use Exception;

// require_once("java/io/File.php"); 
// require_once("java/io/FileInputStream.php");
// require_once("java/io/FileOutputStream.php");
// require_once("java/io/IOException.php");
// require_once("java/io/InputStream.php");
// require_once("java/io/OutputStream.php");
// require_once("java/math/BigDecimal.php");
// require_once("java/sql/Connection.php");
// require_once("java/sql/PreparedStatement.php");
// require_once("java/sql/ResultSet.php");
// require_once("java/sql/ResultSetMetaData.php");
// require_once("java/sql/SQLException.php");
// require_once("java/sql/Statement.php");
// require_once("java/util/Date.php");
// require_once("java/util/Hashtable.php");
// require_once("java/util/UUID.php");
// require_once("org/apache/commons/lang3/StringUtils.php");
// require_once("BP/Difference/ContextHolderUtils.php");
// require_once("BP/En/Attr.php");
// require_once("BP/En/Attrs.php");
// require_once("BP/En/Entities.php");
// require_once("BP/En/Entity.php");
// require_once("BP/En/SQLCash.php");
// require_once( __DIR__ . "/../../BP/Sys/SystemConfig.php");
// require_once("BP/Tools/CRC32Helper.php");
// require_once("BP/Tools/StringHelper.php");
use BP\Sys\SystemConfig;
use BP\Web\WebUser;
abstract class DBAccess {
	public static $CurrentSys_Serial;	// Hashtable<String, Object>
	protected static $KeyLockState;	// Hashtable<String, Object>
	protected static $readCount;	// int
	protected static $lock_OID;	// boolean
	protected static $lock_HT_CfgKey;	// boolean
	protected static $lock_HT;	// Hashtable<String, Object>
	protected static $_HashtableConn;	// Hashtable<String, Connection>
	protected static $lockRunSQL;	// boolean
	public static $RunSQLReturnTableCount;	// int
	protected static $lockRunSQLReTable;	// boolean
	public static function __staticinit() { // static class members
		self::$CurrentSys_Serial = []; //map
		self::$KeyLockState = []; //map
		self::$readCount = -1;
		self::$lock_OID =  FALSE ;
		self::$lock_HT_CfgKey =  FALSE ;
		self::$lock_HT = []; //map
		self::$_HashtableConn = NULL;
		self::$lockRunSQL =  FALSE ;
		self::$RunSQLReturnTableCount = 0;
		self::$lockRunSQLReTable =  FALSE ;
	}
	public static function IsCaseSensitive () 
	{
		if ((DBAccess::IsExitsObject("TEST") ==  TRUE ))
			DBAccess::RunSQL_String("DROP TABLE TEST ");
		if ((DBAccess::IsExitsObject("test") ==  TRUE ))
			DBAccess::RunSQL_String("DROP TABLE test ");
		$mysql = "CREATE TABLE TEST(OID int NOT NULL )";
		DBAccess::RunSQL_String($mysql);
		if ((DBAccess::IsExitsObject("test") ==  FALSE ))
		{
			DBAccess::RunSQL_String("DROP TABLE TEST ");
			return  TRUE ;
		}
		if ((DBAccess::IsExitsTableCol("test", "oid") ==  FALSE ))
		{
			DBAccess::RunSQL_String("DROP TABLE TEST ");
			return  TRUE ;
		}
		return  FALSE ;
	}
	public static function SaveBytesToDB ($bytes, $line, $tableName, $tablePK, $pkVal, $saveToFileField) // [byte[] bytes, String line, String tableName, String tablePK, String pkVal, String saveToFileField]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		try 
		{
			$sql = ((((((("UPDATE " . $tableName) . " SET ") . $saveToFileField) . "=?") . " WHERE ") . $tablePK) . " =?");
			if ((SystemConfig::getAppCenterDBType() == DBType::$MSSQL))
			{
				$conn =DBAccess::getGetAppCenterDBConn_MSSQL();
				$pstmt = $conn->prepareStatement($sql);
			}
			else
				if ((SystemConfig::getAppCenterDBType() == DBType::$Oracle))
				{
					$conn =DBAccess::getGetAppCenterDBConn_Oracle();
					$pstmt = $conn->prepareStatement($sql);
				}
				else
					if ((SystemConfig::getAppCenterDBType() == DBType::$MySQL))
					{
						$conn =DBAccess::getGetAppCenterDBConn_MySQL();
						$pstmt = $conn->prepareStatement($sql);
					}
			if ((SystemConfig::getAppCenterDBType() == DBType::$MySQL))
			{
				$pstmt->setString(1, $line);
			}
			else
			{
				$pstmt->setBytes(1, $bytes);
			}
			$pstmt->setString(2, $pkVal);
			$pstmt->execute();
		}
		catch (Exception $ex)
		{
			throw new Exception($ex);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
		DBAccess::SaveBytesToDB($bytes, $line, $tableName, $tablePK, $pkVal, $saveToFileField);
		return ;
	}
	public static function SaveFileToDB ($fullFileName, $tableName, $tablePK, $pkVal, $saveToFileField) // [String fullFileName, String tableName, String tablePK, String pkVal, String saveToFileField]
	{
		$fs = NULL;
		$bytes = NULL;
		$line = "";
		try 
		{
			if ((SystemConfig::getAppCenterDBType() == DBType::$MySQL))
			{
			/* match: String */
				$line = DataType::ReadTextFile_String($fullFileName);
			}
			else
			{
				$bytes = array();
				fwrite($bytes, file_get_contents($fullFileName));
			}
		}
		catch (Exception $ex)
		{
			$ex->printStackTrace();
		}
// 		finally {
// 		{
// 			if (($fs != NULL))
// 			{
// 				$fs->close();
// 			}
// 		}
// 		}
	}
	public static function SaveBigTextToDB ($docs, $tableName, $tablePK, $pkVal, $saveToFileField) // [String docs, String tableName, String tablePK, String pkVal, String saveToFileField]
	{
		if (($SystemConfig->getAppCenterDBType() == DBType::$MySQL))
		{
			DBAccess::SaveBytesToDB(NULL, $docs, $tableName, $tablePK, $pkVal, $saveToFileField);
			return ;
		}
		DBAccess::SaveBytesToDB($docs->getBytes(), $docs, $tableName, $tablePK, $pkVal, $saveToFileField);
		return ;
	}
	public static function GetFileFromDB ($fullFileName, $tableName, $tablePK, $pkVal, $fileSaveField) // [String fullFileName, String tableName, String tablePK, String pkVal, String fileSaveField]
	{
		$file = $fullFileName;
		if (is_file($file))
		{
			unlink($file);
		}
		$file->createNewFile();
		fopen($file, "w+");
		$strSQL = (((((((("SELECT [" . $fileSaveField) . "] FROM ") . $tableName) . " WHERE ") . $tablePK) . "='") . $pkVal) . "'");
		if ((SystemConfig::getAppCenterDBType() == DBType::$Oracle))
		{
			$strSQL = $strSQL->replace("[", "")->replace("]", "");
		}
		if ((SystemConfig::getAppCenterDBType() == DBType::$MySQL))
		{
			$strSQL = $strSQL->replace("[", "`")->replace("]", "`");
		}
		$dt = DBAccess::RunSQLReturnTable_String($strSQL);
		$byteFile = NULL;
		try 
		{
			if (($dt->Rows->get(0)->size() > 0))
			{
				if ((($dt->Rows->get(0)->getValue(0) != NULL) && !"" /* from: "".equals(dt.Rows.get(0).getValue(0)) */))
				{
					$a = $dt->Rows->get(0)->getValue(0);
					fwrite($file, $a);					
				}
			}
		}
		catch (Exception $ex)
		{
			throw new \Exception($ex);
		}
		return $byteFile;
	}
	public static function GetTextFileFromDB_String_String_String_String_String ($fullFileName, $tableName, $tablePK, $pkVal, $fileSaveField) // [String fullFileName, String tableName, String tablePK, String pkVal, String fileSaveField]
	{
		DBAccess::GetFileFromDB($fullFileName, $tableName, $tablePK, $pkVal, $fileSaveField);
			/* match: String */
		return DataType::ReadTextFile_String($fullFileName);
	}
	public static function GetTextFileFromDB_String_String_String_String_String_String ($fullFileName, $tableName, $tablePK, $pkVal, $fileSaveField, $codeType) // [String fullFileName, String tableName, String tablePK, String pkVal, String fileSaveField, String codeType]
	{
		DBAccess::GetFileFromDB($fullFileName, $tableName, $tablePK, $pkVal, $fileSaveField);
			/* match: String_String */
		return DataType::ReadTextFile_String_String($fullFileName, $codeType);
	}
	public static function DealParasBySQL ($sql, $ps) // [String sql, Paras ps]
	{
		$myps = Paras::constructor__();
		foreach ($ps as $p) 		{
			if (!$sql::contains((":" . $p->ParaName)))
			{
				continue;
			}
			$myps->Add_Para($p);
		}
		return $myps;
	}
	public static function RunSP_String_String_Object ($spName, $paraKey, $paraVal) // [String spName, String paraKey, Object paraVal]
	{
		$pas = Paras::constructor__();
		$pas->Add_String_Object($paraKey, $paraVal);
			/* match: String_Paras */
		return DBAccess::RunSP_String_Paras($spName, $pas);
	}
	public static function RunSP_String ($spName) // [String spName]
	{
		switch (SystemConfig::getAppCenterDBType()) {
			case $MSSQL:
			case $Access:
				throw new \Exception("@没有实现...");
			case $Oracle:
				throw new \Exception("@没有实现...");
			case $Informix:
				throw new \Exception("@没有实现...");
			default:
				throw new \Exception(("Error: " . SystemConfig::getAppCenterDBType()));
		}
	}
	public static function RunSPReturnInt ($spName) // [String spName]
	{
		switch (SystemConfig::getAppCenterDBType()) {
			case $MSSQL:
				throw new \Exception("@没有实现...");
			case $MySQL:
				throw new \Exception("@没有实现...");
			case $Informix:
				throw new \Exception("@没有实现...");
			case $Access:
			case $Oracle:
				throw new \Exception("@没有实现...");
			default:
				throw new \Exception(("Error: " . SystemConfig::getAppCenterDBType()));
		}
	}
	public static function RunSP_String_Paras ($spName, $paras) // [String spName, Paras paras]
	{
		switch (SystemConfig::getAppCenterDBType()) {
			case $MSSQL:
				throw new \Exception("@没有实现...");
			case $MySQL:
				throw new \Exception("@没有实现...");
			case $Oracle:
				throw new \Exception("@没有实现...");
			case $Informix:
				throw new \Exception("@没有实现...");
			default:
				throw new \Exception(("Error " . SystemConfig::getAppCenterDBType()));
		}
	}
	public static function RunSPReTable_String ($spName) // [String spName]
	{
		switch (SystemConfig::getAppCenterDBType()) {
			case $MSSQL:
			case $Access:
				throw new \Exception("@没有实现...");
			case $Oracle:
				throw new \Exception("@没有实现...");
			case $Informix:
				throw new \Exception("@没有实现...");
			default:
				throw new \Exception(("Error " . SystemConfig::getAppCenterDBType()));
		}
	}
	public static function RunSPReTable_String_Paras ($spName, $paras) // [String spName, Paras paras]
	{
		switch (SystemConfig::getAppCenterDBType()) {
			case $MSSQL:
				throw new \Exception("@没有实现...");
			case $Oracle:
				throw new \Exception("@没有实现...");
			case $Informix:
				throw new \Exception("@没有实现...");
			case $Access:
			default:
				throw new \Exception(("Error " . SystemConfig::getAppCenterDBType()));
		}
	}
	public static function copyDirectory ($Src, $Dst) // [String Src, String Dst]
	{
	    if(!file_exists($Dst)){
	        mkdir($Dst, 0777, true);
	    }
		DBAccess::copyFolder($Src, $Dst);
	}
	protected static function copyFolder ($src, $dest) // [File src, File dest]
	{
		try 
		{
			if (is_dir($src))
			{
				if (!file_exists($dest))
				{
					mkdir($dest, 0777, true);
				}
				
				$files = opendir($src);
				while (FALSE !== ($file = readdir($files))){
				    if($file != "." && $file != ".."){
				        if(is_dir($src . $file)){
				            DBAccess::copyFolder($src . $file . '/', $dest . $file . '/');
				        }else {
				            copy($src . $file, $dest . $file);
				        }
				    }
				}
			}
			else
			{
				copy($src, $dest);
			}
		}
		catch (\Exception $e)
		{
			$e->getMessage(); // 
		}
	}
	public static function GenerSequenceNumber ($type) // [String type]
	{
		if ((self::$readCount == -1))
		{
			$tb = DBAccess::RunSQLReturnTable_String("SELECT CfgKey, IntVal FROM Sys_Serial ");
			foreach ($tb->Rows as $row) 			{
				$str = $row->getValue(0)->trim();
				$id = $Integer->parseInt($str);
				try 
				{
					self::$CurrentSys_Serial->put($str, $id);
					self::$KeyLockState->put($str,  FALSE );
				}
				catch (\Exception $e)
				{ /* empty */ }
			}
			++self::$readCount;
		}
		if (!self::$CurrentSys_Serial->containsKey($type))
		{
			DBAccess::RunSQL_String((("insert into Sys_Serial values('" . $type) . "',1 )"));
			return 1;
		}
		while ( TRUE ) 
		{
			while (!$Boolean->parseBoolean(self::$KeyLockState->get($type))) 
			{
				self::$KeyLockState->put($type,  TRUE );
				$cur = $Integer->parseInt(self::$CurrentSys_Serial->get($type));
				if (((++self::$readCount % 10) == 0))
				{
					self::$readCount = 1;
					$n = ($Integer->parseInt(self::$CurrentSys_Serial->get($type)) + 10);
					$ps = Paras::constructor__();
					$ps->Add("intVal", $n);
					$ps->Add_String_String("CfgKey", $type);
					$upd = (((("update Sys_Serial set intVal=" . $SystemConfig->getAppCenterDBVarStr()) . "intVal WHERE CfgKey=") . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
			/* match: String_Paras */
					DBAccess::RunSQL_String_Paras($upd, $ps);
				}
				++$cur;
				self::$CurrentSys_Serial->put($type, $cur);
				self::$KeyLockState->put($type,  FALSE );
				return $cur;
			}
		}
	}
	public static function GenerWhereInPKsString ($dt) // [DataTable dt]
	{
		$pks = "";
		foreach ($dt->Rows as $dr) 		{
			$pks += (("'" . $dr->getValue(0)) . "',");
		}
		if ("" /* from: "".equals(pks) */)
			return "";
		return $pks->substring(0, ($pks->length() - 1));
	}
	public static function GenerOIDByGUID () 
	{
		$i = $CRC32Helper->GetCRC32($UUID->randomUUID());
		if (($i <= 0))
		{
			$i = -$i;
		}
		return $i;
	}
	public static function GenerOIDByGUID_String ($strs) // [String strs]
	{
		$i = $CRC32Helper->GetCRC32($strs);
		if (($i <= 0))
		{
			$i = -$i;
		}
		return $i;
	}
	public static function GenerGUID () 
	{
		return $UUID->randomUUID()->replace("-", "");
	}
	public static function GenerOID () 
	{
		while (self::$lock_OID) 
		self::$lock_OID =  TRUE ;
		if ((DBAccess::RunSQL_String("UPDATE Sys_Serial SET IntVal=IntVal+1 WHERE CfgKey='OID'") == 0))
		{
			DBAccess::RunSQL_String("INSERT INTO Sys_Serial (CfgKey,IntVal) VALUES ('OID',100)");
		}
		$oid = DBAccess::RunSQLReturnValInt_String("SELECT  IntVal FROM Sys_Serial WHERE CfgKey='OID'");
		self::$lock_OID =  FALSE ;
		return $oid;
	}
	public static function GenerOID_String ($cfgKey) // [String cfgKey]
	{
		$ps = Paras::constructor__();
		$ps->Add_String_String("CfgKey", $cfgKey);
		$sql = (("UPDATE Sys_Serial SET IntVal=IntVal+1 WHERE CfgKey=" . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
			/* match: String_Paras */
		$num = DBAccess::RunSQL_String_Paras($sql, $ps);
		if (($num == 0))
		{
			$sql = (("INSERT INTO Sys_Serial (CFGKEY,INTVAL) VALUES ('" . $cfgKey) . "',100)");
			DBAccess::RunSQL_String($sql);
			self::$lock_HT_CfgKey =  FALSE ;
			self::$lock_HT->put($cfgKey, 200);
			return 100;
		}
		$sql = (("SELECT IntVal FROM Sys_Serial WHERE CfgKey=" . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
		$num = DBAccess::RunSQLReturnValInt_String_Paras($sql, $ps);
		return $num;
	}
	public static function GenerOID_String_I ($cfgKey, $getOIDNum) // [String cfgKey, int getOIDNum]
	{
		$ps = Paras::constructor__();
		$ps->Add_String_String("CfgKey", $cfgKey);
		$sql = (((("UPDATE Sys_Serial SET IntVal=IntVal+" . $getOIDNum) . " WHERE CfgKey=") . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
			/* match: String_Paras */
		$num = DBAccess::RunSQL_String_Paras($sql, $ps);
		if (($num == 0))
		{
			$getOIDNum = ($getOIDNum + 100);
			$sql = (((("INSERT INTO Sys_Serial (CFGKEY,INTVAL) VALUES (" . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey,") . $getOIDNum) . ")");
			/* match: String_Paras */
			DBAccess::RunSQL_String_Paras($sql, $ps);
			return 100;
		}
		$sql = (("SELECT  IntVal FROM Sys_Serial WHERE CfgKey=" . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
		return (DBAccess::RunSQLReturnValInt_String_Paras($sql, $ps) - $getOIDNum);
	}
	public static function GenerOIDByKey32 ($intKey) // [String intKey]
	{
		$ps = Paras::constructor__();
		$ps->Add_String_String("CfgKey", $intKey);
		$sql = "";
		$sql = (("UPDATE Sys_Serial SET IntVal=IntVal+1 WHERE CfgKey=" . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
			/* match: String_Paras */
		$num = DBAccess::RunSQL_String_Paras($sql, $ps);
		if (($num == 0))
		{
			$sql = (("INSERT INTO Sys_Serial (CFGKEY,INTVAL) VALUES (" . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey,'100')");
			/* match: String_Paras */
			DBAccess::RunSQL_String_Paras($sql, $ps);
			return $Integer->parseInt(($intKey . "100"));
		}
		$sql = (("SELECT IntVal FROM Sys_Serial WHERE CfgKey=" . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
		$val = DBAccess::RunSQLReturnValInt_String_Paras($sql, $ps);
// 		return $Integer->parseInt(($intKey . (new \Integer($val))));
		return $intKey . $val;
	}
	public static function GenerOID_String_String ($table, $intKey) // [String table, String intKey]
	{
		$ps = Paras::constructor__();
		$ps->Add_String_String("CfgKey", $intKey);
		$sql = "";
		$sql = (((("UPDATE " . $table) . " SET IntVal=IntVal+1 WHERE CfgKey=") . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
			/* match: String_Paras */
		$num = DBAccess::RunSQL_String_Paras($sql, $ps);
		if (($num == 0))
		{
			$sql = (((("INSERT INTO " . $table) . " (CFGKEY,INTVAL) VALUES (") . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey,100)");
			/* match: String_Paras */
			DBAccess::RunSQL_String_Paras($sql, $ps);
			return $Integer->parseInt(($intKey . "100"));
		}
		$sql = (((("SELECT  IntVal FROM " . $table) . " WHERE CfgKey=") . $SystemConfig->getAppCenterDBVarStr()) . "CfgKey");
		$val = DBAccess::RunSQLReturnValInt_String_Paras($sql, $ps);
// 		return $Long->parseLong(($intKey . (new \Integer($val))));
		return $intKey . $val;
	}
	public static function getGetAppCenterDBConn_MSSQL () 
	{
		return $ContextHolderUtils->getInstance()->getDataSource()->getConnection();
	}
	public static function SetConnOfTransactionForMySQL ($buessID, $conn) // [String buessID, Connection conn]
	{
		if ((self::$_HashtableConn == NULL))
			self::$_HashtableConn = []; //map
		self::$_HashtableConn->put($buessID, $conn);
	}
	public static function GetConnOfTransactionForMySQL ($buessID) // [String buessID]
	{
		if (($buessID . NULL))
			return NULL;
		if ((self::$_HashtableConn == NULL))
		{
			self::$_HashtableConn = []; //map
			return NULL;
		}
		if ((self::$_HashtableConn->containsKey($buessID) ==  FALSE ))
			return NULL;
		$conn = self::$_HashtableConn->get($buessID);
		return $conn;
	}
	public static function getGetAppCenterDBConn_MySQL () 
	{
	    $appSettings = SystemConfig::getAppSettings();
	    $database = $appSettings['database'];
// 	    $conn = mysqli_connect($database['hostname'], $database['username'], $database['password'], $database['database']);
	    $dbms=$database['type'];     //数据库类型
	    $host=$database['hostname']; //数据库主机名
	    $dbName=$database['database'];    //使用的数据库
	    $user=$database['username'];      //数据库连接用户名
	    $pass=$database['password'];          //对应的密码
	    $dsn="$dbms:host=$host;dbname=$dbName";
	    $conn = new \PDO($dsn, $user, $pass);
	    return $conn;
// 		return $ContextHolderUtils->getInstance()->getDataSource()->getConnection();
        
	}
	public static function getGetAppCenterDBConn_Oracle () 
	{
		return $ContextHolderUtils->getInstance()->getDataSource()->getConnection();
	}
	public static function getAppCenterDBType () 
	{
		return SystemConfig::getAppCenterDBType();
	}
	public static function CreatePK_String_String_DBType ($tab, $pk, $db) // [String tab, String pk, DBType db]
	{
		$sql = null;
		if ((($tab . NULL) . "" /* from: "".equals(tab) */))
			return ;
		if (DBAccess::IsExitsTabPK($tab))
		{
			return ;
		}
		$sql = (((((("ALTER TABLE " . $tab->toUpperCase()) . " ADD CONSTRAINT ") . $tab) . "pk PRIMARY KEY(") . $pk->toUpperCase()) . ")");
		DBAccess::RunSQL_String($sql);
	}
	public static function CreatePK_String_String_String_DBType ($tab, $pk1, $pk2, $db) // [String tab, String pk1, String pk2, DBType db]
	{
		if (DBAccess::IsExitsTabPK($tab))
		{
			return ;
		}
		$sql = null;
		$sql = (((((((("ALTER TABLE " . $tab->toUpperCase()) . " ADD CONSTRAINT ") . $tab) . "pk  PRIMARY KEY(") . $pk1->toUpperCase()) . ",") . $pk2->toUpperCase()) . ")");
		DBAccess::RunSQL_String($sql);
	}
	public static function CreatePK_String_String_String_String_DBType ($tab, $pk1, $pk2, $pk3, $db) // [String tab, String pk1, String pk2, String pk3, DBType db]
	{
		if (DBAccess::IsExitsTabPK($tab))
		{
			return ;
		}
		$sql = null;
		$sql = (((((((((("ALTER TABLE " . $tab->toUpperCase()) . " ADD CONSTRAINT ") . $tab) . "pk PRIMARY KEY(") . $pk1->toUpperCase()) . ",") . $pk2->toUpperCase()) . ",") . $pk3->toUpperCase()) . ")");
		DBAccess::RunSQL_String($sql);
	}
	public static function CreatIndex_String_String ($table, $pk) // [String table, String pk]
	{
		return ;
	}
// 	abstract static function CreatIndex_String_String_String ($table, $pk1, $pk2); // [String table, String pk1, String pk2]
// 	abstract static function CreatIndex_String_String_String_String ($table, $pk1, $pk2, $pk3); // [String table, String pk1, String pk2, String pk3]
// 	abstract static function CreatIndex_String_String_String_String_String ($table, $pk1, $pk2, $pk3, $pk4); // [String table, String pk1, String pk2, String pk3, String pk4]
	public static function ReadProText ($proName) // [String proName]
	{
		$sql = "";
		switch (SystemConfig::getAppCenterDBType()) {
			case $Oracle:
				$sql = (("SELECT text FROM user_source WHERE name=UPPER('" . $proName) . "') ORDER BY LINE ");
				break;
			default:
				$sql = ("SP_Help  " . $proName);
				break;
		}
		try 
		{
			return DBAccess::RunSQLReturnTable($sql);
		}
		catch (\Exception $e)
		{
			$sql = "select * from Port_Emp WHERE 1=2";
			return DBAccess::RunSQLReturnTable($sql);
		}
	}
	public static function RunSQLScript ($sqlOfScriptFilePath) // [String sqlOfScriptFilePath]
	{
			/* match: String */
		$str = DataType::ReadTextFile_String($sqlOfScriptFilePath);
		$strs = $str->split("[;]", -1);
		foreach ($strs as $s) 		{
			if (is_null($s) || $s == '')
			{
				continue;
			}
			if ($s->contains("--"))
			{
				continue;
			}
			if ($s->contains("/*"))
			{
				continue;
			}
			DBAccess::RunSQL_Paras($s);
		}
	}
	public static function RunSQLScriptGo ($sqlOfScriptFilePath) // [String sqlOfScriptFilePath]
	{
		$str =DataType::ReadTextFile($sqlOfScriptFilePath);
		$strs = $str->split("--GO--");
		foreach ($strs as $s) 		{
			if (is_null($s) || $s == '')
			{
				continue;
			}
			if ($s->contains("/**"))
			{
				continue;
			}
			$mysql = $s->replace("--GO--", "");
			if (is_null(trim($mysql)) || trim($mysql) == '')
			{
				continue;
			}
			DBAccess::RunSQL($mysql);
		}
	}
	public static function RunSQLs ($sql) // [String sql]
	{
		if (is_null($sql) || $sql == '')
		{
			return ;
		}
// 		$sql = $sql->replace("@GO", "~");
// 		$sql = $sql->replace("@", "~");
		$sql = str_replace("@GO", "~", $sql);
		$sql = str_replace("@", "~", $sql);
		
// 		$strs = $sql-> split("[~]", -1);
		$strs = explode('~', $sql, -1);
		foreach ($strs as $str) 		{
			if (is_null($str) || $str == '')
			{
				continue;
			}
			if ((strpos($str, '--') || strpos($str, '/*')))
			{
				continue;
			}
// 			DBAccess::RunSQL_Paras($str);
			DBAccess::RunSQL_String($str);
		}
	}
	public static function RunSQL_Paras ($ps) // [Paras ps]
	{
	    echo $ps->SQL . '::ps-';
			/* match: String_Paras */
		return DBAccess::RunSQL_String_Paras($ps->SQL, $ps);
	}
	public static function RunSQL_String ($sql) // [String sql]
	{
		if ((DataType::IsNullOrEmpty($sql) ==  TRUE ))
		{
			return 1;
		}
		$ps = Paras::constructor__();
		$ps->SQL = $sql;
		return DBAccess::RunSQL_Paras($ps);
	}
	public static function RunSQL_String_String_Object ($sql, $paraKey, $val) // [String sql, String paraKey, Object val]
	{
		$ens = Paras::constructor__();
		$ens->Add_String_Object($paraKey, $val);
			/* match: String_Paras */
		return DBAccess::RunSQL_String_Paras($sql, $ens);
	}
	public static function RunSQL_String_String_Object_String_Object ($sql, $paraKey1, $val1, $paraKey2, $val2) // [String sql, String paraKey1, Object val1, String paraKey2, Object val2]
	{
		$ens = Paras::constructor__();
		$ens->Add_String_Object($paraKey1, $val1);
		$ens->Add_String_Object($paraKey2, $val2);
			/* match: String_Paras */
		return DBAccess::RunSQL_String_Paras($sql, $ens);
	}
	public static function RunSQL_String_String_Object_String_Object_String_Object ($sql, $paraKey1, $val1, $paraKey2, $val2, $k3, $v3) // [String sql, String paraKey1, Object val1, String paraKey2, Object val2, String k3, Object v3]
	{
		$ens = Paras::constructor__();
		$ens->Add_String_Object($paraKey1, $val1);
		$ens->Add_String_Object($paraKey2, $val2);
		$ens->Add_String_Object($k3, $v3);
			/* match: String_Paras */
		return DBAccess::RunSQL_String_Paras($sql, $ens);
	}
	public static function RunSQL_String_Paras ($sql, $paras) // [String sql, Paras paras]
	{
	    if (($sql == NULL) || (trim($sql) == ""))
		{
			return 1;
		}
		self::$lockRunSQL =  TRUE ;
		$result = 0;
		try 
		{
			switch (DBAccess::getAppCenterDBType()) {
			    case DBType::MSSQL:
					$result = DBAccess::RunSQL_200705_SQL($sql, $paras);
					break;
			    case DBType::Oracle:
					$result = DBAccess::RunSQL_200705_Ora($sql->replace("]", "")->replace("[", ""), $paras);
					break;
			    case DBType::MySQL:
					$result = DBAccess::RunSQL_200705_MySQL($sql, $paras);
					break;
				default:
					throw new \Exception("发现未知的数据库连接类型�?");
			}
			return $result;
		}
		catch (\RuntimeException $ex)
		{
			throw $ex;
		}
// 		finally {
// 		{
// 			self::$lockRunSQL =  FALSE ;
// 		}
// 		}
	}
	protected static function RunSQL_200705_SQL ($sql, $paras) // [String sql, Paras paras]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_MSSQL();
			$i = 0;
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				
				$i = $pstmt->ps->execute();
			}
			else
			{
				$stmt = $conn->createStatement();
				$i = $stmt->executeUpdate($sql);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $i));
			}
			return $i;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行更新�?(RunSQL_200705_SQL)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQL_200705_Ora ($sql, $paras) // [String sql, Paras paras]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_Oracle();
			$i = 0;
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$i = $pstmt->executeUpdate();
			}
			else
			{
				$stmt = $conn->createStatement();
				$i = $stmt->executeUpdate($sql);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $i));
			}
			return $i;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行更新�?(RunSQL_200705_Ora)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex::printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQL_200705_MySQL ($sql, $paras) // [String sql, Paras paras]
	{
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		$isTtrack =  FALSE ;
		try 
		{
			$conn = DBAccess::GetConnOfTransactionForMySQL(WebUser::getNo());
			if (($conn == NULL))
				$conn = DBAccess::getGetAppCenterDBConn_MySQL();
			else
				$isTtrack =  TRUE ;
			$i = 0;
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
			    
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				
				$i = $pstmt->ps->execute();
			}
			else
			{
				$stmt = $conn->createStatement();
				$i = $stmt->executeUpdate($sql);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $i));
			}
			return $i;
		}
		catch (Exception $ex)
		{
		    $msg = ((((("@运行更新�?(RunSQL_200705_MySQL)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($stmt != NULL))
// 					$stmt::close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if ((($isTtrack ==  FALSE ) && ($conn != NULL)))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	public static function RunSQLReturnResultSet_String_Paras_Entity_Attrs ($sql, $paras, $en, $attrs) // [String sql, Paras paras, Entity en, Attrs attrs]
	{
		if (is_null($sql) || $sql == '')
		{
			throw new \Exception("要执行的 sql =null ");
		}
		try 
		{
			switch (DBAccess::getAppCenterDBType()) {
				case $MSSQL:
					return DBAccess::RunSQLReturnResultSet_201809_SQL_String_Paras_Entity_Attrs($sql, $paras, $en, $attrs);
				case $Oracle:
					return DBAccess::RunSQLReturnResultSet_201809_Ora_String_Paras_Entity_Attrs($sql, $paras, $en, $attrs);
				case $MySQL:
					return DBAccess::RunSQLReturnResultSet_201809_MySQL_String_Paras_Entity_Attrs($sql, $paras, $en, $attrs);
				default:
					throw new \Exception("@发现未知的数据库连接类型�?");
			}
		}
		catch (\RuntimeException $ex)
		{
			throw $ex;
		}
	}
	public static function RunSQLReturnResultSet_String_Paras_Entities_Attrs ($sql, $paras, $ens, $attrs) // [String sql, Paras paras, Entities ens, Attrs attrs]
	{
		if (is_null($sql) || $sql == '')
		{
			throw new \Exception("要执行的 sql =null ");
		}
		try 
		{
			$rs = NULL;
			switch (DBAccess::getAppCenterDBType()) {
				case $MSSQL:
					return DBAccess::RunSQLReturnResultSet_201809_SQL_String_Paras_Entities_Attrs($sql, $paras, $ens, $attrs);
				case $Oracle:
					return DBAccess::RunSQLReturnResultSet_201809_Ora_String_Paras_Entities_Attrs($sql, $paras, $ens, $attrs);
				case $MySQL:
					return DBAccess::RunSQLReturnResultSet_201809_MySQL_String_Paras_Entities_Attrs($sql, $paras, $ens, $attrs);
				default:
					throw new \Exception("@发现未知的数据库连接类型�?");
			}
		}
		catch (\RuntimeException $ex)
		{
			throw $ex;
		}
	}
	public static function RunSQLReturnTable_String_Paras ($sql, $paras) // [String sql, Paras paras]
	{
		if (is_null($sql) || $sql == '')
		{
			throw new \Exception("要执行的 sql =null ");
		}
		try 
		{
			$dt = NULL;
			switch (DBAccess::getAppCenterDBType()) {
				case $MSSQL:
					$dt = DBAccess::RunSQLReturnTable_200705_SQL($sql, $paras);
					break;
				case $Oracle:
					$dt = DBAccess::RunSQLReturnTable_200705_Ora($sql, $paras);
					break;
				case $MySQL:
					$dt = DBAccess::RunSQLReturnTable_200705_MySQL($sql, $paras);
					break;
				default:
					throw new \Exception("@发现未知的数据库连接类型�?");
			}
			return $dt;
		}
		catch (\RuntimeException $ex)
		{
			throw $ex;
		}
	}
	public static function RunSQLReturnTable_200705_SQL ($sql, $paras) // [String sql, Paras paras]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		if ($sql->trim()->endsWith("WHERE"))
		{
			$sql = $sql->replace("WHERE", "");
		}
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_MSSQL();
			$oratb = DataTable::constructor__String("otb");
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
				$rsmd = $rs->getMetaData();
				$size = $rsmd->getColumnCount();
				for ($i = 0; ($i < $size); ++$i) 
				{
					$oratb->Columns->Add($rsmd->getColumnName(($i + 1)), Para::getDAType_Integer($rsmd->getColumnType(($i + 1))));
				}
				while ($rs->next()) 
				{
					$dr = $oratb->NewRow();
					for ($i = 0; ($i < $size); ++$i) 
					{
						$val = $rs->getObject(($i + 1));
						if (((($dr != NULL) && ($dr->columns->size() > 0)) && ($dr->columns->get($i)->DataType != NULL)))
						{
							if (($dr->columns->get($i)->DataType->contains("Integer") || $dr->columns->get($i)->DataType->contains("Double")))
							{
								if (($val == NULL))
								{
									$dr->setValue($i, 0);
								}
								else
								{
									$dr->setValue_I_Object($i, $val);
								}
							}
							else
							{
								$dr->setValue_I_Object($i, $val);
							}
						}
						else
						{
							$dr->setValue_I_Object($i, $val);
						}
					}
					$oratb->Rows->add($dr);
				}
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
				$rsmd = $rs->getMetaData();
				$size = $rsmd->getColumnCount();
				for ($i = 0; ($i < $size); ++$i) 
				{
					$oratb->Columns->Add($rsmd->getColumnName(($i + 1)), Para::getDAType_Integer($rsmd->getColumnType(($i + 1))));
				}
				while ($rs->next()) 
				{
					$dr = $oratb->NewRow();
					for ($i = 0; ($i < $size); ++$i) 
					{
						$val = $rs->getObject(($i + 1));
						if (((($dr != NULL) && ($dr->columns->size() > 0)) && ($dr->columns->get($i)->DataType != NULL)))
						{
							if (($dr->columns->get($i)->DataType->contains("Integer") || $dr->columns->get($i)->DataType->contains("Double")))
							{
								if (($val == NULL))
								{
									$dr->setValue($i, 0);
								}
								else
								{
									$dr->setValue_I_Object($i, $val);
								}
							}
							else
							{
								$dr->setValue_I_Object($i, $val);
							}
						}
						else
						{
							$dr->setValue_I_Object($i, $val);
						}
					}
					$oratb->Rows->add($dr);
				}
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $oratb->Rows->size()));
			}
			return $oratb;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnTable_200705_SQL)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	public static function RunSQLReturnResultSet_201809_SQL_String_Paras_Entity_Attrs ($sql, $paras, $en, $attrs) // [String sql, Paras paras, Entity en, Attrs attrs]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		if ($sql->trim()->endsWith("WHERE"))
		{
			$sql = $sql->replace("WHERE", "");
		}
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_MSSQL();
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
			}
			if (($rs->next() ==  FALSE ))
				return 0;
			$ht = $en->getRow();
			for ($idx = 0; ($idx < $attrs->size()); ++$idx) 
			{
				$attr = $attrs->get($idx);
				$val = $rs->getObject(($idx + 1));
				if (($val == NULL))
				{
					if (($attr->getIsNum() ==  TRUE ))
						$val = 0;
					else
						$val = "";
				}
				$ht->put($attr->getKey(), $val);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $rs->getRow()));
			}
			return 1;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnTable_200705_SQL)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQLReturnResultSet_201809_SQL_String_Paras_Entities_Attrs ($sql, $paras, $ens, $attrs) // [String sql, Paras paras, Entities ens, Attrs attrs]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		if ($sql->trim()->endsWith("WHERE"))
		{
			$sql = $sql->replace("WHERE", "");
		}
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_MSSQL();
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
			}
			$attr = NULL;
			$myen = $ens->getNewEntity();
			$sqlCash = $myen->getSQLCash();
			$map = $myen->getEnMap();
			while ($rs->next()) 
			{
				$en = $ens->getNewEntity();
				$en->setSQLCash($sqlCash);
				$en->setMap($map);
				$ht = $en->getRow();
				for ($idx = 0; ($idx < $attrs->size()); ++$idx) 
				{
					$attr = $attrs->get($idx);
					$val = $rs->getObject(($idx + 1));
					if (($val == NULL))
					{
						if (($attr->getIsNum() ==  TRUE ))
							$val = 0;
						else
							$val = "";
					}
					$ht->put($attr->getKey(), $val);
				}
				$ens->add($en);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $ens->size()));
			}
			return $ens->size();
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnTable_200705_Ora)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQLReturnTable_200705_Ora ($sql, $paras) // [String sql, Paras paras]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		if ($sql->trim()->endsWith("WHERE"))
		{
			$sql = $sql->replace("WHERE", "");
		}
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_Oracle();
			$oratb = DataTable::constructor__String("otb");
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
				$rsmd = $rs->getMetaData();
				$size = $rsmd->getColumnCount();
				for ($i = 0; ($i < $size); ++$i) 
				{
					$oratb->Columns->Add($rsmd->getColumnName(($i + 1)), Para::getDAType_Integer($rsmd->getColumnType(($i + 1))));
				}
				while ($rs->next()) 
				{
					$dr = $oratb->NewRow();
					for ($i = 0; ($i < $size); ++$i) 
					{
						$val = $rs->getObject(($i + 1));
						if ($dr->columns->get($i)->DataType->contains("BigDecimal"))
						{
							if (($val == NULL))
							{
								$dr->setValue($i, 0);
							}
							else
							{
								$dr->setValue_I_Object($i, $val);
							}
						}
						else
						{
							$dr->setValue_I_Object($i, $val);
						}
					}
					$oratb->Rows->add($dr);
				}
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
				$rsmd = $rs->getMetaData();
				$size = $rsmd->getColumnCount();
				for ($i = 0; ($i < $size); ++$i) 
				{
					$oratb->Columns->Add($rsmd->getColumnName(($i + 1)), Para::getDAType_Integer($rsmd->getColumnType(($i + 1))));
				}
				while ($rs->next()) 
				{
					$dr = $oratb->NewRow();
					for ($i = 0; ($i < $size); ++$i) 
					{
						$val = $rs->getObject(($i + 1));
						if ($dr->columns->get($i)->DataType->contains("BigDecimal"))
						{
							if (($val == NULL))
							{
								$dr->setValue($i, 0);
							}
							else
							{
								$dr->setValue_I_Object($i, $val);
							}
						}
						else
						{
							$dr->setValue_I_Object($i, $val);
						}
					}
					$oratb->Rows->add($dr);
				}
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $oratb->Rows->size()));
			}
			return $oratb;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnTable_200705_Ora)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQLReturnResultSet_201809_Ora_String_Paras_Entity_Attrs ($sql, $paras, $en, $attrs) // [String sql, Paras paras, Entity en, Attrs attrs]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		if ($sql->trim()->endsWith("WHERE"))
		{
			$sql = $sql->replace("WHERE", "");
		}
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_Oracle();
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
			}
			if (($rs->next() ==  FALSE ))
				return 0;
			$ht = $en->getRow();
			for ($idx = 0; ($idx < $attrs->size()); ++$idx) 
			{
				$attr = $attrs->get($idx);
				$val = $rs->getObject(($idx + 1));
				if (($val == NULL))
				{
					if (($attr->getIsNum() ==  TRUE ))
						$val = 0;
					else
						$val = "";
				}
				$ht->put($attr->getKey(), $val);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $rs->getRow()));
			}
			return 1;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnTable_200705_Ora)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQLReturnResultSet_201809_Ora_String_Paras_Entities_Attrs ($sql, $paras, $ens, $attrs) // [String sql, Paras paras, Entities ens, Attrs attrs]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		if ($sql->trim()->endsWith("WHERE"))
		{
			$sql = $sql->replace("WHERE", "");
		}
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_Oracle();
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
			}
			$attr = NULL;
			$myen = $ens->getNewEntity();
			$sqlCash = $myen->getSQLCash();
			$map = $myen->getEnMap();
			while ($rs->next()) 
			{
				$en = $ens->getNewEntity();
				$en->setSQLCash($sqlCash);
				$en->setMap($map);
				$ht = $en->getRow();
				for ($idx = 0; ($idx < $attrs->size()); ++$idx) 
				{
					$attr = $attrs->get($idx);
					$val = $rs->getObject(($idx + 1));
					if (($val == NULL))
					{
						if (($attr->getIsNum() ==  TRUE ))
							$val = 0;
						else
							$val = "";
					}
					$ht->put($attr->getKey(), $val);
				}
				$ens->add($en);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $ens->size()));
			}
			return $ens->size();
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnTable_200705_Ora)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQLReturnTable_200705_MySQL ($sql, $paras) // [String sql, Paras paras]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_MySQL();
			$oratb = DataTable::constructor__String("otb");
			$nameLabel = "";
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
				$rsmd = $rs->getMetaData();
				$size = $rsmd->getColumnCount();
				for ($i = 0; ($i < $size); ++$i) 
				{
					$nameLabel = $rsmd->getColumnLabel(($i + 1));
					$oratb->Columns->Add($nameLabel, Para::getDAType_Integer($rsmd->getColumnType(($i + 1))));
				}
				while ($rs->next()) 
				{
					$dr = $oratb->NewRow();
					for ($i = 0; ($i < $size); ++$i) 
					{
						$val = $rs->getObject(($i + 1));
						if (((($dr != NULL) && ($dr->columns->size() > 0)) && ($dr->columns->get($i)->DataType != NULL)))
						{
							if (($dr->columns->get($i)->DataType->contains("Integer") || $dr->columns->get($i)->DataType->contains("Float")))
							{
								if (($val == NULL))
								{
									$dr->setValue($i, 0);
								}
								else
								{
									$dr->setValue_I_Object($i, $val);
								}
							}
							else
							{
								$dr->setValue_I_Object($i, $val);
							}
						}
						else
						{
							$dr->setValue_I_Object($i, $val);
						}
					}
					$oratb->Rows->add($dr);
				}
			}
			else
			{
				if ("BP" /* from: "BP".equals(SystemConfig.getRunOnPlant()) */)
				{
					$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				}
				else
				{
					$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_READ_ONLY);
				}
				$rs = $stmt->executeQuery($sql);
				$rsmd = $rs->getMetaData();
				$size = $rsmd->getColumnCount();
				for ($i = 0; ($i < $size); ++$i) 
				{
					$nameLabel = $rsmd->getColumnLabel(($i + 1));
					$oratb->Columns->Add($nameLabel, Para::getDAType_Integer($rsmd->getColumnType(($i + 1))));
				}
				while ($rs->next()) 
				{
					$dr = $oratb->NewRow();
					for ($i = 0; ($i < $size); ++$i) 
					{
						$val = $rs->getObject(($i + 1));
						if (((($dr != NULL) && ($dr->columns->size() > 0)) && ($dr->columns->get($i)->DataType != NULL)))
						{
							if (($dr->columns->get($i)->DataType->contains("Integer") || $dr->columns->get($i)->DataType->contains("Float")))
							{
								if (($val == NULL))
								{
									$dr->setValue($i, 0);
								}
								else
								{
									$dr->setValue_I_Object($i, $val);
								}
							}
							else
							{
								$dr->setValue_I_Object($i, $val);
							}
						}
						else
						{
							$dr->setValue_I_Object($i, $val);
						}
					}
					$oratb->Rows->add($dr);
				}
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $oratb->Rows->size()));
			}
			return $oratb;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnTable_200705_MySQL)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQLReturnResultSet_201809_MySQL_String_Paras_Entities_Attrs ($sql, $paras, $ens, $attrs) // [String sql, Paras paras, Entities ens, Attrs attrs]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_MySQL();
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
			}
			$attr = NULL;
			$myen = $ens->getNewEntity();
			$sqlCash = $myen->getSQLCash();
			$map = $myen->getEnMap();
			while ($rs->next()) 
			{
				$en = $ens->getNewEntity();
				$en->setSQLCash($sqlCash);
				$en->setMap($map);
				$ht = $en->getRow();
				for ($idx = 0; ($idx < $attrs->size()); ++$idx) 
				{
					$attr = $attrs->get($idx);
					$val = $rs->getObject(($idx + 1));
					if (($val == NULL))
					{
						if (($attr->getIsNum() ==  TRUE ))
							$val = 0;
						else
							$val = "";
					}
					$ht->put($attr->getKey(), $val);
				}
				$ens->add($en);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $rs->getRow()));
			}
			return $ens->size();
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnResultSet_201809_MySQL)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function RunSQLReturnResultSet_201809_MySQL_String_Paras_Entity_Attrs ($sql, $paras, $en, $attrs) // [String sql, Paras paras, Entity en, Attrs attrs]
	{
		$rs = NULL;
		$conn = NULL;
		$stmt = NULL;
		$pstmt = NULL;
		try 
		{
			$conn = DBAccess::getGetAppCenterDBConn_MySQL();
			if (((NULL != $paras) && (sizeof($paras) > 0)))
			{
				$pstmt = NamedParameterStatement::constructor__Connection_String($conn, $sql);
				DBAccess::PrepareCommand($pstmt, $paras);
				$rs = $pstmt->executeQuery();
			}
			else
			{
				$stmt = $conn->createStatement($ResultSet->TYPE_SCROLL_SENSITIVE, $ResultSet->CONCUR_UPDATABLE);
				$rs = $stmt->executeQuery($sql);
			}
			if (($rs->next() ==  FALSE ))
				return 0;
			$ht = $en->getRow();
			for ($idx = 0; ($idx < $attrs->size()); ++$idx) 
			{
				$attr = $attrs->get($idx);
				$val = $rs->getObject(($idx + 1));
				if (($val == NULL))
				{
					if (($attr->getIsNum() ==  TRUE ))
						$val = 0;
					else
						$val = "";
				}
				$ht->put($attr->getKey(), $val);
			}
			if (Log::isLoggerDebugEnabled())
			{
				Log::DefaultLogWriteLineDebug(("SQL: " . $sql));
				Log::DefaultLogWriteLineDebug(((("Param: " . $paras->getDebugInfo()) . ", Result: Rows=") . $rs->getRow()));
			}
			return 1;
		}
		catch (Exception $ex)
		{
			$msg = ((((("@运行查询�?(RunSQLReturnResultSet_201809_MySQL)出错。\n  @SQL: " . $sql) . "\n  @Param: ") . $paras->getDebugInfo()) . "\n  @异常信息: ") . str_replace("\n", " ", $ex->getMessage()));
			/* match: String */
			Log::DefaultLogWriteLineError_String($msg);
			throw new \Exception($msg);
		}
// 		finally {
// 		{
// 			try 
// 			{
// 				if (($rs != NULL))
// 					$rs->close();
// 				if (($stmt != NULL))
// 					$stmt->close();
// 				if (($pstmt != NULL))
// 					$pstmt->close();
// 				if (($conn != NULL))
// 					$conn->close();
// 			}
// 			catch (\Exception $ex)
// 			{
// 				$ex->printStackTrace();
// 			}
// 		}
// 		}
	}
	protected static function PrepareCommand ($ps, $params) // [NamedParameterStatement ps, Paras params]
	{
	    if (((NULL == $params) || (sizeof($params) <= 0)))
		{
		    
			return ;
		}
		try 
		{
			foreach ($params as $para) 			{
				if (($para->DAType . String))
				{
					try 
					{
						if ((($para->val != NULL) && !$para->val->equals("")))
						{
							$ps->setString($para->ParaName, $String->valueOf($para->val));
						}
						else
						{
							$ps->setString($para->ParaName, "");
						}
					}
					catch (\Exception $e)
					{
						$ps->setString($para->ParaName, "");
					}
				}
				else
					if (($para->DAType == Long))
					{
						$ps->setLong($para->ParaName, $para->val);
					}
					else
						if (($para->DAType == Integer))
						{
							$ps->setInt($para->ParaName, ( ($para->val instanceof String) ? $Integer->parseInt(("" . $para->val)) : $para->val ));
						}
						else
							if (($para->DAType == Float))
							{
								$ps->setFloat($para->ParaName, $para->val);
							}
							else
								if (($para->DAType == Double))
								{
									$ps->setDouble($para->ParaName, $para->val);
								}
								else
									if (($para->DAType == BigDecimal))
									{
										$ps->setBigDecimal($para->ParaName, $para->val);
									}
									else
										if (($para->DAType == Date))
										{
											$date = $para->val;
											if (($date == NULL))
											{
			/* match: String_Date */
												$ps->setDate_String_Date($para->ParaName, NULL);
											}
											else
											{
			/* match: String_Date */
												$ps->setDate_String_Date($para->ParaName, $date);
											}
										}
										else
											if (($para->DAType == Boolean))
											{
												$ps->setBoolean($para->ParaName, $para->val);
											}
			}
		}
		catch (\Exception $ex)
		{
		    $msg = ("@运行查询�?(PrepareCommand)出错  @异常信息�?" . str_replace("\n", " ", $ex->getMessage()));
			/* match: String_Throwable */
			Log::DefaultLogWriteLineError_String_Throwable($msg, $ex);
		}
	}
	public static function RunSQLReturnTable_Paras ($ps) // [Paras ps]
	{
			/* match: String_Paras */
		return DBAccess::RunSQLReturnTable_String_Paras($ps->SQL, $ps);
	}
	public static function RunSQLReturnTable_String ($sql) // [String sql]
	{
		$ps = Paras::constructor__();
			/* match: String_Paras */
		return DBAccess::RunSQLReturnTable_String_Paras($sql, $ps);
	}
	public static function RunSQLReturnTable_String_String_Object_String_Object ($sql, $key1, $v1, $key2, $v2) // [String sql, String key1, Object v1, String key2, Object v2]
	{
		$ens = Paras::constructor__();
		$ens->Add_String_Object($key1, $v1);
		$ens->Add_String_Object($key2, $v2);
			/* match: String_Paras */
		return DBAccess::RunSQLReturnTable_String_Paras($sql, $ens);
	}
	public static function RunSQLReturnTable_String_String_Object ($sql, $key, $val) // [String sql, String key, Object val]
	{
		$ens = Paras::constructor__();
		$ens->Add_String_Object($key, $val);
			/* match: String_Paras */
		return DBAccess::RunSQLReturnTable_String_Paras($sql, $ens);
	}
	public static function RunSQLReturnDataSet ($sqls) // [String sqls]
	{
		$ds = DataSet::constructor__();
		$str = $sqls->split(";");
		foreach ($str as $s) 		{
			if (("" /* from: "".equals(s) */ || (NULL == $s)))
				continue;
			$dt = DBAccess::RunSQLReturnTable_Paras($s);
			$ds->Tables->add($dt);
		}
		return $ds;
	}
	public static function RunSQLReturnValFloat_Paras ($ps) // [Paras ps]
	{
			/* match: String_Paras_F */
		return DBAccess::RunSQLReturnValFloat_String_Paras_F($ps->SQL, $ps, 0);
	}
	public static function RunSQLReturnValFloat_String_Paras_F ($sql, $ps, $val) // [String sql, Paras ps, float val]
	{
		$ps->SQL = $sql;
		$obj = DBAccess::RunSQLReturnVal_Paras($ps);
		try 
		{
			if ((($obj == NULL) || $obj->equals("")))
			{
				return $val;
			}
			else
			{
				return $Float->parseFloat($obj);
			}
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception(((($ex->getMessage() . $sql) . " @OBJ=") . $obj), $ex);
		}
	}
	public static function RunSQLReturnValFloat_String_F ($sql, $isNullAsVal) // [String sql, float isNullAsVal]
	{
			/* match: String_Paras_F */
		return DBAccess::RunSQLReturnValFloat_String_Paras_F($sql, Paras::constructor__(), $isNullAsVal);
	}
	public static function RunSQLReturnValFloat_String ($sql) // [String sql]
	{
		try 
		{
			return $Float->parseFloat(DBAccess::RunSQLReturnVal_String($sql));
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception(($ex->getMessage() . $sql), $ex);
		}
	}
	public static function RunSQLReturnValInt_Paras_I ($ps, $IsNullReturnVal) // [Paras ps, int IsNullReturnVal]
	{
		return DBAccess::RunSQLReturnValInt_String_Paras_I($ps->SQL, $ps, $IsNullReturnVal);
	}
	public static function RunSQLReturnValInt_String_I ($sql, $IsNullReturnVal) // [String sql, int IsNullReturnVal]
	{
		$obj = "";
		$obj = DBAccess::RunSQLReturnVal_String($sql);
		if ((($obj == NULL) || $obj->equals("")))
		{
			return $IsNullReturnVal;
		}
		else
		{
			if (($obj->indexOf(".") != -1))
			{
				return $Integer->parseInt($obj->substring(0, $obj->indexOf(".")));
			}
			else
			{
				return $Integer->parseInt($obj);
			}
		}
	}
	public static function RunSQLReturnValInt_String_I_Paras ($sql, $IsNullReturnVal, $paras) // [String sql, int IsNullReturnVal, Paras paras]
	{
		$obj = "";
			/* match: String_Paras */
		$obj = DBAccess::RunSQLReturnVal_String_Paras($sql, $paras);
		if ((($obj == NULL) || $obj->equals("")))
		{
			return $IsNullReturnVal;
		}
		else
		{
			return $Integer->parseInt($obj);
		}
	}
	public static function RunSQLReturnValDecimal_String_BigDecimal_I ($sql, $IsNullReturnVal, $blws) // [String sql, BigDecimal IsNullReturnVal, int blws]
	{
		$ps = Paras::constructor__();
		$ps->SQL = $sql;
		return DBAccess::RunSQLReturnValDecimal_Paras_BigDecimal_I($ps, $IsNullReturnVal, $blws);
	}
	public static function RunSQLReturnValDecimal_Paras_BigDecimal_I ($ps, $IsNullReturnVal, $blws) // [Paras ps, BigDecimal IsNullReturnVal, int blws]
	{
		try 
		{
			$obj = DBAccess::RunSQLReturnVal_Paras($ps);
			if ((($obj == NULL) || "" /* from: "".equals(obj.toString()) */))
			{
				return $IsNullReturnVal;
			}
			else
			{
// 				$d = new BigDecimal($Double->valueOf($obj));
// 				return $d->setScale($blws, $BigDecimal->ROUND_HALF_UP);
                return round($obj, 2);
			}
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception((("RunSQLReturnValDecimal " . $ex->getMessage()) . $ps->SQL), $ex);
		}
	}
	public static function RunSQLReturnCOUNT ($sql) // [String sql]
	{
		return DBAccess::RunSQLReturnTable_String($sql)->$Rows->size();
	}
	public static function RunSQLReturnValInt_Paras ($ps) // [Paras ps]
	{
			/* match: String_Paras */
		$str = DBAccess::RunSQLReturnString_String_Paras($ps->SQL, $ps);
		if ($str->contains("."))
		{
			$str = $str->substring(0, $str->indexOf("."));
		}
		try 
		{
			if (is_null($str) || $str == '')
			{
				return 0;
			}
			return $Integer->parseInt($str);
		}
		catch (\RuntimeException $ex)
		{
			throw new \Exception((((("@" . $ps->SQL) . "   Val=") . $str) . $ex->getMessage()), $ex);
		}
	}
	public static function RunSQLReturnValInt_String ($sql) // [String sql]
	{
		$obj = DBAccess::RunSQLReturnVal_String($sql);
		if (($obj == NULL))
		{
			throw new \Exception((("@没有获取您要查询的数�?,请检查SQL:" . $sql) . " @关于查询出来的详细信息已经记录日志文件，请处理�??"));
		}
		$s = $obj;
		if ($s->contains("."))
		{
			$s = $s->substring(0, $s->indexOf("."));
		}
		return $Integer->parseInt($s);
	}
	public static function RunSQLReturnValInt_String_Paras ($sql, $paras) // [String sql, Paras paras]
	{
		return DBAccess::RunSQLReturnValInt_String_Paras_I($sql, $paras, 0);
	}
	public static function RunSQLReturnValInt_String_Paras_I ($sql, $paras, $isNullAsVal) // [String sql, Paras paras, int isNullAsVal]
	{
		try 
		{
			/* match: String_Paras */
			return $Integer->parseInt(DBAccess::RunSQLReturnVal_String_Paras($sql, $paras));
		}
		catch (\Exception $e)
		{
			return $isNullAsVal;
		}
	}
	public static function RunSQLReturnString_String_Paras ($sql, $ps) // [String sql, Paras ps]
	{
		if (($ps == NULL))
		{
			$ps = Paras::constructor__();
		}
			/* match: String_Paras */
		$obj = DBAccess::RunSQLReturnVal_String_Paras($sql, $ps);
		if (($obj == NULL))
		{
			return NULL;
		}
		else
		{
			return $obj;
		}
	}
	public static function RunSQLReturnString_String ($sql) // [String sql]
	{
			/* match: String_Paras */
		return DBAccess::RunSQLReturnString_String_Paras($sql, Paras::constructor__());
	}
	public static function RunSQLReturnStringIsNull_Paras_String ($ps, $isNullAsVal) // [Paras ps, String isNullAsVal]
	{
		$v = DBAccess::RunSQLReturnString_Paras($ps);
		if (($v . NULL))
		{
			return $isNullAsVal;
		}
		else
		{
			return $v;
		}
	}
	public static function RunSQLReturnStringIsNull_String_String ($sql, $isNullAsVal) // [String sql, String isNullAsVal]
	{
			/* match: String_Paras */
		$s = DBAccess::RunSQLReturnString_String_Paras($sql, Paras::constructor__());
		if (($s . NULL))
		{
			return $isNullAsVal;
		}
		return $s;
	}
	public static function RunSQLReturnString_Paras ($ps) // [Paras ps]
	{
			/* match: String_Paras */
		return DBAccess::RunSQLReturnString_String_Paras($ps->SQL, $ps);
	}
	public static function RunSQLReturnVal_String_String_Object ($sql, $pkey, $val) // [String sql, String pkey, Object val]
	{
		$ps = Paras::constructor__();
		$ps->Add_String_Object($pkey, $val);
			/* match: String_Paras */
		return DBAccess::RunSQLReturnVal_String_Paras($sql, $ps);
	}
	public static function RunSQLReturnVal_String_Paras ($sql, $paras) // [String sql, Paras paras]
	{
		++self::$RunSQLReturnTableCount;
		$dt = NULL;
		try 
		{
			switch ($SystemConfig->getAppCenterDBType()) {
				case $Oracle:
					$dt = DBAccess::RunSQLReturnTable_200705_Ora($sql, $paras);
					break;
				case $MSSQL:
					$dt = DBAccess::RunSQLReturnTable_200705_SQL($sql, $paras);
					break;
				case $MySQL:
					$dt = DBAccess::RunSQLReturnTable_200705_MySQL($sql, $paras);
					break;
				default:
					throw new \Exception("@没有判断的数据库类型");
			}
		}
		catch (\RuntimeException $e)
		{
			return NULL;
		}
		if (($dt->Rows->size() == 0))
		{
			return NULL;
		}
		return $dt->Rows->get(0)->getValue(0);
	}
	public static function RunSQLReturnVal_Paras ($ps) // [Paras ps]
	{
			/* match: String_Paras */
		return DBAccess::RunSQLReturnVal_String_Paras($ps->SQL, $ps);
	}
	public static function RunSQLReturnVal_String ($sql) // [String sql]
	{
		++self::$RunSQLReturnTableCount;
		$dt = NULL;
		switch ($SystemConfig->getAppCenterDBType()) {
			case $Oracle:
				$dt = DBAccess::RunSQLReturnTable_200705_Ora($sql, Paras::constructor__());
				break;
			case $MSSQL:
				$dt = DBAccess::RunSQLReturnTable_200705_SQL($sql, Paras::constructor__());
				break;
			case $MySQL:
				$dt = DBAccess::RunSQLReturnTable_200705_MySQL($sql, Paras::constructor__());
				break;
			default:
				throw new \Exception("@没有判断的数据库类型");
		}
		if (($dt->Rows->size() == 0))
			return NULL;
		return $dt->Rows->get(0)->getValue(0);
	}
	public static function IsExits_String ($sql) // [String sql]
	{
		if ((DBAccess::RunSQLReturnVal_String($sql) == NULL))
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public static function IsExits_String_Paras ($sql, $ps) // [String sql, Paras ps]
	{
			/* match: String_Paras */
		if ((DBAccess::RunSQLReturnVal_String_Paras($sql, $ps) == NULL))
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public static function IsExitsTabPK ($tab) // [String tab]
	{
		$ps = Paras::constructor__();
		$ps->Add("Tab", $tab);
		$sql = "";
		switch (DBAccess::getAppCenterDBType()) {
			case $MSSQL:
				$sql = "SELECT column_name, table_name,CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name =:Tab ";
				break;
			case $Oracle:
				$sql = "SELECT constraint_name, constraint_type,search_condition, r_constraint_name  from user_constraints WHERE table_name = upper(:Tab) AND constraint_type = 'P'";
				break;
			case $MySQL:
				$sql = (("SELECT column_name, table_name, CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name =:Tab and table_schema='" . $SystemConfig->getAppCenterDBDatabase()) . "' ");
				break;
			default:
				throw new \Exception("数据库连接配置失败！ ");
		}
			/* match: String_Paras */
		$dt = DBAccess::RunSQLReturnTable_String_Paras($sql, $ps);
		if (($dt->Rows->size() >= 1))
		{
			return  TRUE ;
		}
		else
		{
			return  FALSE ;
		}
	}
	public static function IsExitsObject ($obj) // [String obj]
	{
		$ps = Paras::constructor__();
		$ps->Add_String_String("obj", $obj);
		switch (DBAccess::getAppCenterDBType()) {
			case $Oracle:
				if (($obj->indexOf(".") != -1))
				{
					$obj = $obj->split("[.]", -1)[1];
				}
				$sql = (("select object_name from all_objects WHERE  object_name = upper(:obj) and OWNER='" . SystemConfig::getUser()->toUpperCase()) . "' ");
			/* match: String_Paras */
				return DBAccess::IsExits_String_Paras($sql, $ps);
			case $MSSQL:
			/* match: String */
				return DBAccess::IsExits_String((("SELECT name  FROM sysobjects  WHERE  name = '" . $obj) . "'"));
			case $MySQL:
				if (($obj->equals("") . (NULL . $obj)))
				{
					return  TRUE ;
				}
				if (($obj->indexOf(".") != -1))
				{
					$obj = $obj->split("[.]", -1)[1];
				}
			/* match: String */
				return DBAccess::IsExits_String((((("SELECT table_name, table_type FROM information_schema.tables  WHERE table_name = '" . $obj) . "' AND   TABLE_SCHEMA='") . SystemConfig::getAppCenterDBDatabase()) . "' "));
			default:
				throw new \Exception("没有识别的数据库编号");
		}
	}
	public static function IsExitsTableCol ($table, $col) // [String table, String col]
	{
		$ps = Paras::constructor__();
		$ps->Add_String_String("tab", $table);
		$ps->Add_String_String("col", $col);
		$i = 0;
		switch (DBAccess::getAppCenterDBType()) {
			case $MSSQL:
				$i = DBAccess::RunSQLReturnValInt_String_I((((("SELECT  COUNT(*) FROM information_schema.COLUMNS  WHERE TABLE_NAME='" . $table) . "' AND COLUMN_NAME='") . $col) . "'"), 0);
				break;
			case $MySQL:
				$sql = (((((("select count(*) FROM information_schema.columns WHERE TABLE_SCHEMA='" . SystemConfig::getAppCenterDBDatabase()) . "' AND table_name ='") . $table) . "' and column_Name='") . $col) . "'");
				$i = DBAccess::RunSQLReturnValInt_String($sql);
				break;
			case $Oracle:
				if (($table->indexOf(".") != -1))
				{
					$table = $table->split("[.]", -1)[1];
				}
				$i = DBAccess::RunSQLReturnValInt_String_Paras("SELECT COUNT(*) from user_tab_columns  WHERE table_name= upper(:tab) AND column_name= upper(:col) ", $ps);
				break;
			default:
				throw new \Exception("error");
		}
		if (($i == 1))
		{
			return  TRUE ;
		}
		else
		{
			return  FALSE ;
		}
	}
	public static function GetTableSchema ($tableName) // [String tableName]
	{
		$sql = "";
		switch ($SystemConfig->getAppCenterDBType()) {
			case $MSSQL:
				$sql = (("SELECT column_name as FName, data_type as FType, CHARACTER_MAXIMUM_LENGTH as FLen , column_name as FDesc FROM information_schema.columns where table_name='" . $tableName) . "'");
				break;
			case $Oracle:
				$sql = (("SELECT COLUMN_NAME as FName,DATA_TYPE as FType,DATA_LENGTH as FLen,COLUMN_NAME as FDesc FROM all_tab_columns WHERE table_name = upper('" . $tableName) . "')");
				break;
			case $MySQL:
				$sql = (((("SELECT COLUMN_NAME FName,DATA_TYPE FType,CHARACTER_MAXIMUM_LENGTH FLen,COLUMN_COMMENT FDesc FROM information_schema.columns WHERE table_name='" . $tableName) . "' and TABLE_SCHEMA='") . $SystemConfig->getAppCenterDBDatabase()) . "'");
				break;
			default:
				break;
		}
		$dt =DBAccess::RunSQLReturnTable($sql);
		if (($SystemConfig->getAppCenterDBType() == DBType::$Oracle))
		{
			$dt->Columns->get("FNAME")->ColumnName = "FName";
			$dt->Columns->get("FTYPE")->ColumnName = "FType";
			$dt->Columns->get("FLEN")->ColumnName = "FLen";
			$dt->Columns->get("FDESC")->ColumnName = "FDesc";
		}
		return $dt;
	}
	public static function isCanInstall () 
	{
		$checkSql = "CREATE TABLE CHECKDB(NO int)";
		try 
		{
			DBAccess::RunSQL_String($checkSql);
			$checkSql = "CREATE VIEW CHECKDBVIEW AS SELECT * FROM CHECKDB";
			DBAccess::RunSQL_String($checkSql);
			$checkSql = "DROP TABLE CHECKDB";
			DBAccess::RunSQL_String($checkSql);
			$checkSql = "DROP VIEW CHECKDBVIEW";
			DBAccess::RunSQL_String($checkSql);
		}
		catch (\Exception $e)
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public static function DropTablePK ($table) // [String table]
	{
		$pkName = DBAccess::GetTablePKName($table);
		if (($pkName . NULL))
		{
			return ;
		}
		$sql = "";
		switch ($SystemConfig->getAppCenterDBType()) {
			case $Oracle:
			case $MSSQL:
				$sql = ((("ALTER TABLE " . $table) . " DROP CONSTRAINT ") . $pkName);
				break;
			case $MySQL:
				$sql = (("ALTER TABLE " . $table) . " DROP primary key");
				break;
			default:
				Log::DebugWriteError((("DBAccess DropTablePK " . "@不支持的数据库类�?.") . $SystemConfig->getAppCenterDBType()));
				throw new \Exception(("@不支持的数据库类�?." . $SystemConfig->getAppCenterDBType()));
		}
		DBAccess::RunSQL($sql);
	}
	public static function GetTablePKName ($table) // [String table]
	{
		$ps = Paras::constructor__();
		$ps->Add("Tab", $table);
		$sql = "";
		switch (DBAccess::getAppCenterDBType()) {
			case $Access:
				return NULL;
			case $MSSQL:
				$sql = (("SELECT CONSTRAINT_NAME,column_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name ='" . $table) . "'");
				break;
			case $Oracle:
				$sql = (("SELECT constraint_name, constraint_type,search_condition, r_constraint_name  from user_constraints WHERE table_name = upper('" . $table) . "') AND constraint_type = 'P'");
				break;
			case $MySQL:
				$sql = (((("SELECT CONSTRAINT_NAME , column_name, table_name CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name ='" . $table) . "' and table_schema='") . $SystemConfig->getAppCenterDBDatabase()) . "' ");
				break;
			case $Informix:
				$sql = (("SELECT * FROM sysconstraints c inner join systables t on c.tabid = t.tabid where t.tabname = lower('" . $table) . "') and constrtype = 'P'");
				break;
			default:
				Log::DebugWriteError(("DBAccess GetTablePKName " . "@没有判断的数据库类型."));
				throw new \Exception("@没有判断的数据库类型.");
		}
		$dt = DBAccess::RunSQLReturnTable_String($sql);
		if (($dt->Rows->size() == 0))
		{
			return NULL;
		}
		return $dt->getValue_I_I(0, 0);
	}
	public static function GetBigTextFromDB ($tableName, $tablePK, $pkVal, $fileSaveField) // [String tableName, String tablePK, String pkVal, String fileSaveField]
	{
		$byteFile = DBAccess::GetByteFromDB($tableName, $tablePK, $pkVal, $fileSaveField);
		if (($byteFile == NULL))
		{
			return NULL;
		}
		return new String($byteFile);
	}
	public static function GetByteFromDB ($tableName, $tablePK, $pkVal, $fileSaveField) // [String tableName, String tablePK, String pkVal, String fileSaveField]
	{
		return NULL;
	}
	public static function DoTransactionBegin () 
	{
		$conn = $ContextHolderUtils->getInstance()->getDataSource()->getConnection();
		$conn->setAutoCommit( FALSE );
		DBAccess::SetConnOfTransactionForMySQL($BP->Web->WebUser->getNo(), $conn);
	}
	public static function DoTransactionCommit () 
	{
		$id = $BP->Web->WebUser->getNo();
		$conn = DBAccess::GetConnOfTransactionForMySQL($id);
		$conn->commit();
		$conn->setAutoCommit( TRUE );
		$conn->close();
		self::$_HashtableConn->remove($id);
	}
	public static function DoTransactionRollback () 
	{
		$buessID = $BP->Web->WebUser->getNo();
		$conn = DBAccess::GetConnOfTransactionForMySQL($buessID);
		$conn->rollback();
		$conn->setAutoCommit( TRUE );
		$conn->close();
		self::$_HashtableConn->remove($buessID);
	}
	public static function ToLower ($dt) // [DataTable dt]
	{
		for ($i = 0; ($i < $dt->Columns->size()); ++$i) 
		{
			$dt->Columns->get($i)->ColumnName = $dt->Columns->get($i)->ColumnName->toLowerCase();
		}
		return $dt;
	}
	public static function TestIsConnection () 
	{
		try 
		{
			switch (SystemConfig::getAppCenterDBType()) {
				case $MSSQL:
					DBAccess::RunSQLReturnString("SELECT 1+2 ");
					break;
				case $Oracle:
				case $MySQL:
					DBAccess::RunSQLReturnString("SELECT 1+2 FROM DUAL ");
					break;
				case $Informix:
					DBAccess::RunSQLReturnString("SELECT 1+2 FROM DUAL ");
					break;
				default:
					break;
			}
			return  TRUE ;
		}
		catch (\RuntimeException $ex)
		{
			return  FALSE ;
		}
	}
	public static function RunSQLReturnTable_String_I_I_String_String_String ($sql, $pageSize, $pageIdx, $key, $orderKey, $orderType) // [String sql, int pageSize, int pageIdx, String key, String orderKey, String orderType]
	{
		switch (DBAccess::getAppCenterDBType()) {
			case $MSSQL:
				return DBAccess::RunSQLReturnTable_201612_SQL($sql, $pageSize, $pageIdx, $key, $orderKey, $orderType);
			case $Oracle:
				return DBAccess::RunSQLReturnTable_201612_Ora($sql, $pageSize, $pageIdx, $orderKey, $orderType);
			case $MySQL:
				return DBAccess::RunSQLReturnTable_201612_MySql($sql, $pageSize, $pageIdx, $key, $orderKey, $orderType);
			default:
				throw new \Exception("@未涉及的数据库类型！");
		}
	}
	protected static function RunSQLReturnTable_201612_SQL ($sql, $pageSize, $pageIdx, $key, $orderKey, $orderType) // [String sql, int pageSize, int pageIdx, String key, String orderKey, String orderType]
	{
		$sqlstr = "";
		$orderType = ( (is_null($orderType)) ? "ASC" : $orderType->toUpperCase() );
		if (($pageIdx < 1))
		{
			$pageIdx = 1;
		}
		if (($pageIdx == 1))
		{
			$sqlstr = ((((("SELECT TOP " . $pageSize) . " * FROM (") . $sql) . ") T1") . (( (is_null($orderKey)) ? "" : $String->format(" ORDER BY T1.%1$s %2$s", $orderKey, $orderType) )));
		}
		else
		{
			$sqlstr = (((((((((((((((((((((("SELECT TOP " . $pageSize) . " * FROM (") . $sql) . ") T1") . " WHERE T1.") . $key) . (( ($orderType->equals("ASC")) ? " > " : " < " ))) . "(") . " SELECT ") . (( ($orderType->equals("ASC")) ? "MAX(T3." : "MIN(T3." ))) . $key) . ") FROM (") . " SELECT TOP ((") . $pageIdx) . " - 1) * 10) T2.") . $key) . "FROM (") . $sql) . ") T2") . (( (is_null($orderKey)) ? "" : $String->format(" ORDER BY T2.%1$s %2$s", $orderKey, $orderType) ))) . " ) T3)") . (( (is_null($orderKey)) ? "" : $String->format(" ORDER BY T.%1$s %2$s", $orderKey, $orderType) )));
		}
		return DBAccess::RunSQLReturnTable_String($sqlstr);
	}
	protected static function RunSQLReturnTable_201612_Ora ($sql, $pageSize, $pageIdx, $orderKey, $orderType) // [String sql, int pageSize, int pageIdx, String orderKey, String orderType]
	{
		if (($pageIdx < 1))
		{
			$pageIdx = 1;
		}
		$start = (((($pageIdx - 1)) * $pageSize) + 1);
		$end = ($pageSize * $pageIdx);
		$orderType = ( (is_null($orderType)) ? "ASC" : $orderType->toUpperCase() );
		$sqlstr = (((((((("SELECT * FROM ( SELECT T1.*, ROWNUM RN " . "FROM (SELECT * FROM  (") . $sql) . ") T2 ") . (( (is_null($orderType)) ? "" : $String->format("ORDER BY T2.%1$s %2$s", $orderKey, $orderType) ))) . ") T1 WHERE ROWNUM <= ") . $end) . " ) WHERE RN >=") . $start);
		return DBAccess::RunSQLReturnTable_String($sqlstr);
	}
	protected static function RunSQLReturnTable_201612_MySql ($sql, $pageSize, $pageIdx, $key, $orderKey, $orderType) // [String sql, int pageSize, int pageIdx, String key, String orderKey, String orderType]
	{
		$sqlstr = "";
		$orderType = ( (is_null($orderType)) ? "ASC" : $orderType->toUpperCase() );
		if (($pageIdx < 1))
		{
			$pageIdx = 1;
		}
		$sqlstr = (((((((((((((("SELECT * FROM (" . $sql) . ") T1 WHERE T1.") . $key) . (( ($orderType->equals("ASC")) ? " >= " : " <= " ))) . "(SELECT T2.") . $key) . " FROM (") . $sql) . ") T2") . (( (is_null($orderKey)) ? "" : $String->format(" ORDER BY T2.%1$s %2$s", $orderKey, $orderType) ))) . " LIMIT ") . (((($pageIdx - 1)) * $pageSize))) . ",1) LIMIT ") . $pageSize);
		return DBAccess::RunSQLReturnTable_String($sqlstr);
	}
	public static function IsView_String ($tabelOrViewName) // [String tabelOrViewName]
	{
			/* match: String_DBType */
		return DBAccess::IsView_String_DBType($tabelOrViewName, $SystemConfig->getAppCenterDBType());
	}
	public static function IsView_String_DBType ($tabelOrViewName, $dbType) // [String tabelOrViewName, DBType dbType]
	{
		$sql = "";
		switch ($dbType) {
			case $Oracle:
				$sql = "SELECT TABTYPE  FROM TAB WHERE UPPER(TNAME)=:v";
			/* match: String_String_Object */
				$oradt = DBAccess::RunSQLReturnTable_String_String_Object($sql, "v", $tabelOrViewName->toUpperCase());
				if (($oradt->Rows->size() == 0))
				{
					throw new \Exception((("@表不存在[" . $tabelOrViewName) . "]"));
				}
				if ($oradt->Rows->get(0)->getValue(0)->toUpperCase()->trim()->equals("VIEW"))
				{
					return  TRUE ;
				}
				else
				{
					return  FALSE ;
				}
			case $Access:
				$sql = (("select   Type   from   msysobjects   WHERE   UCASE(name)='" . $tabelOrViewName->toUpperCase()) . "'");
				$dtw = DBAccess::RunSQLReturnTable_String($sql);
				if (($dtw->Rows->size() == 0))
				{
					throw new \Exception((("@表不存在[" . $tabelOrViewName) . "]"));
				}
				if ($dtw->Rows->get(0)->getValue(0)->trim()->equals("5"))
				{
					return  TRUE ;
				}
				else
				{
					return  FALSE ;
				}
			case $MSSQL:
				$sql = (("select xtype from sysobjects WHERE name =" . $SystemConfig->getAppCenterDBVarStr()) . "v");
			/* match: String_String_Object */
				$dt1 = DBAccess::RunSQLReturnTable_String_String_Object($sql, "v", $tabelOrViewName);
				if (($dt1->Rows->size() == 0))
				{
					throw new \Exception((("@表不存在[" . $tabelOrViewName) . "]"));
				}
				if ($dt1->Rows->get(0)->getValue(0)->toUpperCase()->trim()->equals("V"))
				{
					return  TRUE ;
				}
				else
				{
					return  FALSE ;
				}
			case $Informix:
				$sql = (("select tabtype from systables where tabname = '" . $tabelOrViewName->toLowerCase()) . "'");
				$dtaa = DBAccess::RunSQLReturnTable_String($sql);
				if (($dtaa->Rows->size() == 0))
				{
					throw new \Exception((("@表不存在[" . $tabelOrViewName) . "]"));
				}
				if ($dtaa->Rows->get(0)->getValue(0)->toUpperCase()->trim()->equals("V"))
				{
					return  TRUE ;
				}
				else
				{
					return  FALSE ;
				}
			case $MySQL:
				$sql = (((("SELECT Table_Type FROM information_schema.TABLES WHERE table_name='" . $tabelOrViewName) . "' and table_schema='") . $SystemConfig->getAppCenterDBDatabase()) . "'");
				$dt2 = DBAccess::RunSQLReturnTable_String($sql);
				if (($dt2->Rows->size() == 0))
				{
					throw new \Exception((("@表不存在[" . $tabelOrViewName) . "]"));
				}
				if ($dt2->Rows->get(0)->getValue(0)->toUpperCase()->trim()->equals("VIEW"))
				{
					return  TRUE ;
				}
				else
				{
					return  FALSE ;
				}
			default:
				throw new \Exception("@没有做的判断�?");
		}
	}
}
DBAccess::__staticinit(); // initialize static vars for this class on load
?>
